package com.ctshk.app.bus.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.req.OperationByLikeReq;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.bus.dto.es.BusStopsCacheCityDTO;
import com.ctshk.rpc.bus.dto.es.BusStopsCacheDTO;
import com.ctshk.rpc.bus.req.BusStopsDictListQueryReq;
import com.ctshk.rpc.bus.service.IBusProductAppService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value = "巴士服务-缓存管理",tags = "巴士服务—缓存管理")
@RestController
@RequestMapping("/bus/order/cache")
public class BusCacheController extends BaseController {

	@DubboReference
	IBusProductAppService busOrderAppServiceImpl;
	
	@ApiOperation(value="巴士订单-缓存-初始化", notes="巴士订单-缓存-初始化")
	@OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "巴士订单-缓存-初始化", operDesc = "巴士订单-缓存-初始化")
	@GetMapping("/init")
	public Result lineInit() {
		return busOrderAppServiceImpl.busCacheInit();
	}

	@ApiOperation(value="巴士订单-缓存-按时间更新", notes="巴士订单-缓存-按时间更新")
	@OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "巴士订单-缓存-按时间更新", operDesc = "巴士订单-缓存-按时间更新")
	@GetMapping("/update/bytime")
	public Result busCacheUpdateByTime() {
		return busOrderAppServiceImpl.busCacheUpdateByTime();
	}

	@ApiOperation(value="巴士订单-缓存-按巴士线路id更新", notes="巴士订单-缓存-按巴士线路id更新")
	@OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "巴士订单-缓存-按巴士线路id更新", operDesc = "巴士订单-缓存-按巴士线路id更新")
	@PostMapping("/update/byid")
	public Result busCacheUpdateById(@RequestBody @NotNull List<Long> ids) {
		return busOrderAppServiceImpl.busCacheUpdateById(ids);
	}

	@ApiOperation(value="巴士订单-缓存-查询缓存站点主数据列表", notes="巴士订单-缓存-查询缓存站点主数据列表")
	@OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "巴士订单-缓存-查询缓存站点主数据列表", operDesc = "巴士订单-缓存-查询缓存站点主数据列表")
    @PostMapping("queryCacheStopsList")
    public Result<List<BusStopsCacheDTO>> queryCacheStopsList(@RequestBody BusStopsDictListQueryReq req) {
    	return busOrderAppServiceImpl.queryCacheStopsList(req);
    }
	
	@ApiOperation(value="巴士订单-缓存-查询缓存城市主数据列表", notes="巴士订单-缓存-查询缓存城市主数据列表")
	@OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "巴士订单-缓存-查询缓存城市主数据列表", operDesc = "巴士订单-缓存-查询缓存城市主数据列表")
    @PostMapping("queryCacheCityList")
    public Result<List<BusStopsCacheCityDTO>> queryCacheCityList(@RequestBody OperationByLikeReq req) {
    	return busOrderAppServiceImpl.queryCacheCityList(req);
    }
}